home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / usr / bin / select-editor < prev    next >
Text File  |  2008-09-03  |  1KB  |  46 lines

  1. #!/bin/sh
  2.  
  3. # To generate localization information, run:
  4. #   xgettext -o - -L Shell select-editor
  5.  
  6. # Ensure that $HOME/.selected_editor is writeable
  7. touch $HOME/.selected_editor || exit 1
  8.  
  9. editors=`update-alternatives --list editor | wc -l`
  10. if [ $editors -gt 1 ]; then
  11.     echo "`gettext '\nSelect an editor.  To change later, run'`" "'select-editor'."
  12.     i=0
  13.     editors=`update-alternatives --list editor`
  14.     for e in $editors; do
  15.         i=`expr $i + 1`
  16.         desc="          "
  17.         if [ $e = "/bin/nano" ]; then
  18.             desc="<---- ` gettext 'easiest'`"
  19.             simple=$i
  20.         fi
  21.         echo "  $i. $e\t\t$desc"
  22.     done
  23.     echo ""
  24.     selected=x
  25.     while /bin/true; do
  26.         if [ -z "$selected" -a ! -z "$simple" ]; then
  27.             selected="$simple"
  28.         elif ! test $selected -gt 0 2>/dev/null; then
  29.             read -p "`gettext 'Choose'` 1-$i [$simple]: " -r selected
  30.         elif ! test $selected -le $i 2>/dev/null; then
  31.             read -p "`gettext 'Choose'` 1-$i [$simple]: " -r selected
  32.         else
  33.             break
  34.         fi
  35.     done
  36.     i=0
  37.     for e in $editors; do
  38.         i=`expr $i + 1`
  39.         if [ $i -eq $selected ]; then
  40.             echo "# Generated by /usr/bin/select-editor" > $HOME/.selected_editor
  41.             echo "SELECTED_EDITOR=\"$e\"" >> $HOME/.selected_editor && exit 0
  42.         fi
  43.     done
  44. fi
  45. exit 1
  46.